<?php
// +----------------------------------------------------------------------------
// | Tke团队版权所属 [三十年河东三十年河西,莫欺少年穷.!]
// +----------------------------------------------------------------------------
// | Copyright (c) 2014 http://www.itdaodan.com All rights reserved.
// +----------------------------------------------------------------------------
// | Author: fzh<fanzhaohai@hrbjjhh.com>
// +----------------------------------------------------------------------------

namespace Admin\Model;
use Admin\Model\BaseModel;
/**
 * 客户信息模型
 */
class ServiceCustomerHouseModel extends BaseModel {

    /* 自动验证规则 */
    protected $_validate = array(
        array('province_id', 'number', '请选择省份', self::MUST_VALIDATE, '', self::MODEL_BOTH),
        array('province_id', array(0), '请选择省份', self::MUST_VALIDATE, 'notin', self::MODEL_BOTH),
        array('city_id', 'number', '请选择城市', self::MUST_VALIDATE, '', self::MODEL_BOTH),
        array('city_id', array(0), '请选择城市', self::MUST_VALIDATE, 'notin', self::MODEL_BOTH),
        array('ward_id', 'number', '请选择行政区', self::MUST_VALIDATE, '', self::MODEL_BOTH),
        array('ward_id', array(0), '请选择行政区', self::MUST_VALIDATE, 'notin', self::MODEL_BOTH),
        array('village_id', 'number', '请选择小区', self::VALUE_VALIDATE, '', self::MODEL_BOTH),
//         array('village_id', array(0), '请选择小区', self::VALUE_VALIDATE, 'notin', self::MODEL_BOTH),
        array('house_price', 'isDouble', '平米价格必须是数字', self::VALUE_VALIDATE, 'callback', self::MODEL_BOTH),
        array('decoration_meter', 'number', '装修平米必须是数字', self::VALUE_VALIDATE, '', self::MODEL_BOTH),
        array('decoration_meter', '1,6', '装修平米不能超过6个数字', self::VALUE_VALIDATE, 'length', self::MODEL_BOTH),
        array('decoration_budget', 'isDouble', '装修预算必须是数字', self::VALUE_VALIDATE, 'callback', self::MODEL_BOTH),
    );

    /* 自动完成规则 */
    protected $_auto = array(
//         array('province_id', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('city_id', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('ward_id', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('village_id', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('house_price', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('decoration_meter', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('decoration_budget', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('home_time', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//         array('decoration_time', 'htmlspecialchars', self::MODEL_BOTH, 'function'),
//        array('house_price', 'formatMoney', self::MODEL_BOTH, 'function'),
//        array('decoration_budget', 'formatMoney', self::MODEL_BOTH, 'function'),
        array('home_time', 'strtotime', self::MODEL_BOTH, 'function'),
        array('decoration_time', 'strtotime', self::MODEL_BOTH, 'function'),
    );

    public function isDouble($num){
        if(!is_numeric($num)){
            return false;
        }else{
            return true;
        }
    }

    /**
     * @todo 返回主键
     * @see \Think\Model::getPk()
     */
    public function getPk(){
        return 'house_id';
    }
}